package service

import (
	"fmt"
	"gitee.com/golang-lib/go-framework/core/biz"
	"sys-admin/app/dao"
)

var RoleService = new(roleService)

type roleService struct{}

func (u *roleService) List(page, size int) (list []dao.Role, count int64) {
	db := dao.DB.Debug().Model(&dao.Role{})

	err := db.Count(&count).Error
	biz.AssertErrIsNil(err, "查询角色count失败")
	err = db.Limit(size).Offset(size * (page - 1)).Find(&list).Error
	biz.AssertErrIsNil(err, "查询角色列表失败")
	return list, count
}

func (u *roleService) Add(role *dao.Role) {
	result := dao.DB.Create(&role)
	fmt.Printf("影响的行数：%d", result.RowsAffected)
	//role.ID, result.Error
}

func (u *roleService) Update() {
	//u.roleRepository.Update()
}

func (u *roleService) Delete() {
	//u.roleRepository.Delete()
}

func (u *roleService) FindByID(id int64) {
	//u.roleRepository.FindByID(id)
}
